/** Copyright 2020 Tianshu AI Platform. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================
 */

<template>
  <div v-loading="loading" class="textEditor" v-on="listeners">
    <pre>{{ txt }}</pre>
  </div>
</template>
<script>
import { onMounted } from '@vue/composition-api';

export default {
  name: 'TextEditor',
  props: {
    txt: String,
    loading: {
      type: Boolean,
      default: false,
    },
  },
  setup(props, ctx) {
    const { listeners } = ctx;

    onMounted(() => {
      ctx.emit('mount');
    });

    return {
      listeners,
    };
  },
};
</script>
<style lang="scss" scoped>
.textEditor {
  max-height: 40vh;
  overflow: auto;

  pre {
    width: 100%;
    min-height: 100%;
    padding: 20px;
    line-height: 1.8;
    word-break: break-word;
    white-space: pre-wrap;
    background: #fff;
  }
}
</style>
